package com.jorado.core.statistics.builder;

import com.jorado.core.statistics.utils.StatisticsServiceLoader;

import java.util.Set;

public class BuilderManager {

    private static BuilderManager builderManager = new BuilderManager();

    private Set<DBStatisticsServiceBuilder> dbStatisticsServiceBuilders;

    private Set<HttpStatisticsServiceBuilder> httpStatisticsServiceBuilders;

    private Set<RedisStatisticsServiceBuilder> redisStatisticsServiceBuilders;

    private BuilderManager() {
        loadBuilders();
    }

    public static BuilderManager instance() {
        return builderManager;
    }

    public void loadBuilders() {
        dbStatisticsServiceBuilders = StatisticsServiceLoader.loadServiceName(DBStatisticsServiceBuilder.class);
        httpStatisticsServiceBuilders = StatisticsServiceLoader.loadServiceName(HttpStatisticsServiceBuilder.class);
        redisStatisticsServiceBuilders = StatisticsServiceLoader.loadServiceName(RedisStatisticsServiceBuilder.class);
    }

    public Set<DBStatisticsServiceBuilder> getDBStatisticsServiceBuilders() {
        return dbStatisticsServiceBuilders;
    }

    public Set<HttpStatisticsServiceBuilder> getHttpStatisticsServiceBuilders() {
        return httpStatisticsServiceBuilders;
    }

    public Set<RedisStatisticsServiceBuilder> getRedisStatisticsServiceBuilders() {
        return redisStatisticsServiceBuilders;
    }
}
